package cn.mw.cmdb.entity;

import cn.mw.components.mongodb.anno.CMDBProperty;
import cn.mw.components.mongodb.anno.CMDBRelations;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;

@Data
@Document("mw_cmdbmd_instance_import_result_info")
@Schema(description = "实例导入结果")
@ColumnWidth(20)
public class InstanceImportResultInfo {

    @Schema(description = "任务ID")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String historyId;

    @Schema(description = "资产名称")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @ExcelProperty(value = "资产名称", order = 0)
    private String instanceName;

    @Schema(description = "实例Id")
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @ExcelProperty(value = "实例Id", order = 1)
    private String instanceId;

    @Schema(description = "模型id")
    @CMDBProperty
    private String modelId;

    @Schema(description = "资产子类型")
    @ExcelProperty(value = "资产子类型", order = 2)
    @CMDBRelations(targetClass = ModelInfo.class, targetField = "modelName", localField = "modelId", foreignField = "_id")
    private String modelName;

    @Schema(description = "金融元分类ID")
    @CMDBProperty
    private String financeParentModelId;

    @Schema(description = "金融元分类")
    @ExcelProperty(value = "金融元分类", order = 3)
    @CMDBRelations(targetClass = ModelInfo.class, targetField = "modelName", localField = "financeParentModelId", foreignField = "_id")
    private String financeParentModelName;

    @Schema(description = "数据行")
    @CMDBProperty
    @ExcelProperty(value = "数据行", order = 4)
    private String rowIndex;

    @Schema(description = "操作类型")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    @ExcelProperty(value = "操作类型", order = 5)
    private String operateType;

    @Schema(description = "操作人")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    @ExcelProperty(value = "操作人", order = 6)
    private String operator;

    @Schema(description = "操作时间")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    @ExcelProperty(value = "操作日期", order = 7)
    private String operateDate;

    @Schema(description = "操作结果")
    @CMDBProperty(searchType = PropertyTypeSwitch.ID)
    private Boolean result;

    @Transient
    @ExcelProperty(value = "操作结果", order = 8)
    private String resultMsg;

    @Schema(description = "失败原因")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    @ExcelProperty(value = "失败原因", order = 9)
    private String errorMsg;

    @Schema(description = "excel行")
    @CMDBProperty
    private Integer rowNo;
}
